package cn.terminus.data.customer.customlabel.impl;

import cn.terminus.common.customer.bean.customlabel.dto.*;
import cn.terminus.data.customer.customlabel.dao.CustomLabelDao;
import cn.terminus.data.customer.customlabel.mapper.CustomLabelMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomLabel)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:52
 */
@Repository
public class CustomLabelDaoImpl implements CustomLabelDao {
    @Resource
    private CustomLabelMapper customLabelMapper;

    @Override
    public Integer add(CustomLabelNewDto dto) {
        return customLabelMapper.add(dto);
    }

    @Override
    public Integer update(CustomLabelEditDto dto) {
        return customLabelMapper.update(dto);
    }

    @Override
    public List<CustomLabelResultDto> gets(CustomLabelGetsDto dto) {
        return customLabelMapper.gets(dto);
    }

    @Override
    public List<CustomLabelResultDto> query(CustomLabelQueryDto dto) {
        return customLabelMapper.query(dto);
    }

    @Override
    public Integer delete(CustomLabelDeleteDto dto) {
        return customLabelMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomLabelResultDto> page(CustomLabelQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomLabelResultDto> result = (Page<CustomLabelResultDto>) customLabelMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomLabelResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer addMulti(List<CustomLabelNewDto> labelNewDtoList) {
        return customLabelMapper.addMulti(labelNewDtoList);
    }
}
